import 'package:flutter/material.dart';
import 'package:getx_scaffold/getx_scaffold.dart';
import 'package:oramemo/common/langs/text_key.dart';

enum TranscriptionStatus {
  completed,
  failed,
  inProgress,
}

class TranscriptionItem extends StatelessWidget {
  final String title;
  final String date;
  final String duration;
  final TranscriptionStatus status;

  const TranscriptionItem({
    super.key,
    required this.title,
    required this.date,
    required this.duration,
    required this.status,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(bottom: 16),
      padding: const EdgeInsets.all(16),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(12),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            title,
            style: const TextStyle(
              fontSize: 16,
              fontWeight: FontWeight.w500,
            ),
          ),
          const SizedBox(height: 8),
          Row(
            children: [
              Text(
                '${TextKey.transcriptionItemDate.tr}: $date',
                style: TextStyle(
                  color: Colors.grey[600],
                  fontSize: 14,
                ),
              ),
              const Spacer(),
              Text(
                '${TextKey.transcriptionItemDuration.tr}: $duration',
                style: const TextStyle(
                  color: Colors.blue,
                  fontSize: 14,
                ),
              ),
            ],
          ),
          const SizedBox(height: 8),
          _buildStatusChip(),
        ],
      ),
    );
  }

  Widget _buildStatusChip() {
    Color backgroundColor;
    String text;
    Color textColor;

    switch (status) {
      case TranscriptionStatus.completed:
        backgroundColor = const Color(0xFFE8FFF3);
        text = TextKey.transcriptionItemStatusCompleted.tr;
        textColor = const Color(0xFF00B578);
        break;
      case TranscriptionStatus.failed:
        backgroundColor = const Color(0xFFFFE8E8);
        text = TextKey.transcriptionItemStatusFailed.tr;
        textColor = const Color(0xFFFF4D4F);
        break;
      case TranscriptionStatus.inProgress:
        backgroundColor = const Color(0xFFE8F7FF);
        text = TextKey.transcriptionItemStatusInProgress.tr;
        textColor = const Color(0xFF1890FF);
        break;
    }

    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
      decoration: BoxDecoration(
        color: backgroundColor,
        borderRadius: BorderRadius.circular(4),
      ),
      child: Text(
        text,
        style: TextStyle(
          color: textColor,
          fontSize: 12,
        ),
      ),
    );
  }
}